package com.api.regression.group.createinternallink;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import com.api.test.AbstractApiTest;
import com.zyncro.api.IGroupApiService;
import com.zyncro.api.exceptions.ZyncroApiException;

@ContextConfiguration(locations = { "classpath:/group/group-context.xml" })
public class CreateInternalLinkInvalid extends AbstractApiTest {

	@Value("#{editgroupdocuments['user.editor'].appId}")
	private String userUrn;

	@Value("#{editgroupdocuments['user.editor'].password}")
	private String userPassword;

	@Value("#{editgroupdocuments['group.toCreate'].urn}")
	private String groupUrn;

	@Value("#{editgroupdocuments['group.toCreate'].folderUrn}")
	private String folderUrn;

	@Value("#{editgroupdocuments['group.toCreate'].linkUrn}")
	private String linkUrn;

	@Value("#{editgroupdocuments['group.toCreate'].shortcutUrn}")
	private String shortcutUrn;

	@BeforeClass
	protected void loginUser() throws Exception {

		getApi().login(userUrn, userPassword);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testCreateFolderInternalLink() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).createInternaLink(groupUrn, folderUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testCreateLinkInternalLink() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).createInternaLink(groupUrn, linkUrn);
	}

	@Test(expectedExceptions = { ZyncroApiException.class })
	public void testCreateShortcutInternalLink() throws ZyncroApiException {

		getApi().getService(IGroupApiService.class).createInternaLink(groupUrn, shortcutUrn);
	}
}
